package com.CI.CreateAccount.Commands
{
	import com.CI.CreateAccount.Business.AddDelegate;
	import com.CI.CreateAccount.Control.AddUserEvent;
	import com.CI.CreateAccount.Control.AddAminEvent;
	
	import com.adobe.cairngorm.business.Responder;
	import com.adobe.cairngorm.commands.Command;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import mx.controls.Alert;
	
	public class AddCommands implements Command,Responder
	{
		public function execute(event : CairngormEvent) : void
		{
			var str : String = event.type;
			
			if(str == 'createUser')
			{
				var userEvent : AddUserEvent = AddUserEvent(event);
				getDelegate.sendObject(userEvent.user);
			}
			else
			{
				var adminEvent : AddAminEvent = AddAminEvent(event);
				getDelegate.sendObject(adminEvent.admin);
			}
		}
		
		public function onFault(event : *=null) : void
		{
			
		}
		
		public function onResult(event : *=null) : void
		{
		}
		
		protected function get getDelegate(): AddDelegate
		{
			return new AddDelegate(this);
		}

	}
}